Introduction | Windows Helpline Q&A Directory 

Shut down Windows 98 automatically

Sometimes it can be useful to be able to shut down Windows automatically. Is there an easy way to do this?

You can shut down or reboot the computer from a batch file that carried out some unattended task or installed some files. Or simlply use the Windows Task Scheduler to shut down your computer at a set time. The command below will shut down or reboot the computer or log off the current user:

rundll32.exe shell32.dll,shexitWindowsEx n

The action is determined by the number n, a number which is one of the following:

0 - log off
1 - shut down
2 - reboot

To these values you may add four if you want to force the action (in other words, ignore any messages like 'Do you want to save this file?' which applications may display when they receive the request to shut down.) This will ensure the computer shuts down no matter what is running at the time, but it can result in lost work. Add eight if you want the computer to be powered off (assuming it supports software-controlled power off.) So to force shutdown with power off, n would be 13.

To use the command from a batch file just make it the final command to be executed in the batch file. To use it from the Task Scheduler use the Add New Task Wizard to add rundll32.exe as a task, then edit the task properties to add the parameters shown above to the command line.
 © 2002 PC Advisor